/*
* Configuration of module: Dem
*
* Created by:   qinminyuan
* Copyright:    (C)  
*
* Configured for (MCU):    MCU
*
* Module vendor:           ArcCore
* Generator version:       01.00
*/
#ifdef USE_DEM
/* ============================ [ INCLUDES  ] ====================================================== */
#include "Dem.h"

#ifdef USE_NVM
#include "NvM.h"
#endif
#ifdef USE_DCM
#include "Dcm.h"
#endif
/* ============================ [ MACROS    ] ====================================================== */
#define INDEX_OF_FFIDCLASS_FreezeFrameClass1 0
#define INDEX_OF_FFCLASS_FreezeFrameClass 0
#define INDEX_OF_EDRC_ExtendedDataRecordClass_1 0
#define INDEX_OF_EDRC_ExtendedDataRecordClass_2 1
/* ============================ [ TYPES     ] ====================================================== */
/* ============================ [ DECLARES  ] ====================================================== */
extern Std_ReturnType Dem_CallbackGetExtDataRecord_ExtendedDataRecordClass_1(Dem_EventIdType eventId, uint8 *ExtendedDataRecord);
extern Std_ReturnType Dem_CallbackGetExtDataRecord_ExtendedDataRecordClass_2(Dem_EventIdType eventId, uint8 *ExtendedDataRecord);
/* ============================ [ DATAS     ] ====================================================== */
static const Dem_PidOrDidType Dem_PidOrDid[]=
{
	{ /* FreezeFrameClass1 */
		.DidConditionCheckReadFnc=NULL,
		.DidIdentifier=0,
		.DidReadDataLengthFnc=NULL,
		.DidReadFnc=NULL,
		.PidOrDidSize=0,
		.Arc_EOL =  FALSE
	},
	{ 
		.Arc_EOL = TRUE
	}
};

static const Dem_ExtendedDataRecordClassType Dem_ExtendedDataRecord[]=
{
	{ /* ExtendedDataRecordClass_1 */
		.RecordNumber=0x01,
		.DataSize=1,
		.UpdateRule=DEM_UPDATE_RECORD_VOLATILE,
		.CallbackGetExtDataRecord=Dem_CallbackGetExtDataRecord_ExtendedDataRecordClass_1,
		.InternalDataElement=DEM_NO_ELEMENT,
	},
	{ /* ExtendedDataRecordClass_2 */
		.RecordNumber=0x02,
		.DataSize=1,
		.UpdateRule=DEM_UPDATE_RECORD_VOLATILE,
		.CallbackGetExtDataRecord=Dem_CallbackGetExtDataRecord_ExtendedDataRecordClass_2,
		.InternalDataElement=DEM_NO_ELEMENT,
	},
};

static const Dem_DTCClassType DTCClassRef_DTCClass_EHYVideoError=
{
	.DTC=0xA20002,
	.DTCFunctionalUnit=0,
	.DTCKind=DEM_DTC_KIND_ALL_DTCS,
};

static const Dem_DTCClassType DTCClassRef_DTCClass_EHYSensorError=
{
	.DTC=0xA20102,
	.DTCFunctionalUnit=0,
	.DTCKind=DEM_DTC_KIND_ALL_DTCS,
};

static const Dem_DTCClassType DTCClassRef_DTCClass_EHYLCDError=
{
	.DTC=0xA20204,
	.DTCFunctionalUnit=0,
	.DTCKind=DEM_DTC_KIND_ALL_DTCS,
};

static const Dem_DTCClassType DTCClassRef_DTCClass_EHYPowerVoltageError=
{
	.DTC=0xA203A1,
	.DTCFunctionalUnit=0,
	.DTCKind=DEM_DTC_KIND_ALL_DTCS,
};

static const Dem_DTCClassType DTCClassRef_DTCClass_EHYI2CBusError=
{
	.DTC=0xA20488,
	.DTCFunctionalUnit=0,
	.DTCKind=DEM_DTC_KIND_ALL_DTCS,
};

static const Dem_DTCClassType DTCClassRef_DTCClass_VIU2IPCanBusOff=
{
	.DTC=0xC08788,
	.DTCFunctionalUnit=0,
	.DTCKind=DEM_DTC_KIND_ALL_DTCS,
};

static const Dem_DTCClassType DTCClassRef_DTCClass_LostCommunicationWithVIU2=
{
	.DTC=0xC14787,
	.DTCFunctionalUnit=0,
	.DTCKind=DEM_DTC_KIND_ALL_DTCS,
};

static const Dem_EventClassType EventClass_EventClass_EHYVideoError = 
{
	.ConsiderPtoStatus=TRUE,
	.EventDestination={ DEM_DTC_ORIGIN_PRIMARY_MEMORY },
	.EventPriority=1,
	.FFPrestorageSupported=TRUE,
	.HealingAllowed=TRUE,
	.OperationCycleRef=DEM_ACTIVE,
	.HealingCycleRef=DEM_ACTIVE,
	.HealingCycleCounter=40,
	.ConfirmationCycleCounterThreshold=1,
	.PreDebounceAlgorithmClass=NULL,
};

static const Dem_EventClassType EventClass_EventClass_EHYSensorError = 
{
	.ConsiderPtoStatus=TRUE,
	.EventDestination={ DEM_DTC_ORIGIN_PRIMARY_MEMORY },
	.EventPriority=1,
	.FFPrestorageSupported=TRUE,
	.HealingAllowed=TRUE,
	.OperationCycleRef=DEM_ACTIVE,
	.HealingCycleRef=DEM_ACTIVE,
	.HealingCycleCounter=40,
	.ConfirmationCycleCounterThreshold=1,
	.PreDebounceAlgorithmClass=NULL,
};

static const Dem_EventClassType EventClass_EventClass_EHYLCDError = 
{
	.ConsiderPtoStatus=TRUE,
	.EventDestination={ DEM_DTC_ORIGIN_PRIMARY_MEMORY },
	.EventPriority=1,
	.FFPrestorageSupported=TRUE,
	.HealingAllowed=TRUE,
	.OperationCycleRef=DEM_ACTIVE,
	.HealingCycleRef=DEM_ACTIVE,
	.HealingCycleCounter=40,
	.ConfirmationCycleCounterThreshold=1,
	.PreDebounceAlgorithmClass=NULL,
};

static const Dem_EventClassType EventClass_EventClass_EHYPowerVoltageError = 
{
	.ConsiderPtoStatus=TRUE,
	.EventDestination={ DEM_DTC_ORIGIN_PRIMARY_MEMORY },
	.EventPriority=1,
	.FFPrestorageSupported=TRUE,
	.HealingAllowed=TRUE,
	.OperationCycleRef=DEM_ACTIVE,
	.HealingCycleRef=DEM_ACTIVE,
	.HealingCycleCounter=40,
	.ConfirmationCycleCounterThreshold=1,
	.PreDebounceAlgorithmClass=NULL,
};

static const Dem_EventClassType EventClass_EventClass_EHYI2CBusError = 
{
	.ConsiderPtoStatus=TRUE,
	.EventDestination={ DEM_DTC_ORIGIN_PRIMARY_MEMORY },
	.EventPriority=1,
	.FFPrestorageSupported=TRUE,
	.HealingAllowed=TRUE,
	.OperationCycleRef=DEM_ACTIVE,
	.HealingCycleRef=DEM_ACTIVE,
	.HealingCycleCounter=40,
	.ConfirmationCycleCounterThreshold=1,
	.PreDebounceAlgorithmClass=NULL,
};

static const Dem_EventClassType EventClass_EventClass_VIU2IPCanBusOff = 
{
	.ConsiderPtoStatus=TRUE,
	.EventDestination={ DEM_DTC_ORIGIN_PRIMARY_MEMORY },
	.EventPriority=1,
	.FFPrestorageSupported=TRUE,
	.HealingAllowed=TRUE,
	.OperationCycleRef=DEM_ACTIVE,
	.HealingCycleRef=DEM_ACTIVE,
	.HealingCycleCounter=40,
	.ConfirmationCycleCounterThreshold=1,
	.PreDebounceAlgorithmClass=NULL,
};

static const Dem_EventClassType EventClass_EventClass_LostCommunicationWithVIU2 = 
{
	.ConsiderPtoStatus=TRUE,
	.EventDestination={ DEM_DTC_ORIGIN_PRIMARY_MEMORY },
	.EventPriority=1,
	.FFPrestorageSupported=TRUE,
	.HealingAllowed=TRUE,
	.OperationCycleRef=DEM_ACTIVE,
	.HealingCycleRef=DEM_ACTIVE,
	.HealingCycleCounter=40,
	.ConfirmationCycleCounterThreshold=1,
	.PreDebounceAlgorithmClass=NULL,
};

static const Dem_PidOrDidType *FreezeFrameClass_FFIdClassRef[] = 
{
	&Dem_PidOrDid[INDEX_OF_FFIDCLASS_FreezeFrameClass1],
	NULL
};

static const Dem_FreezeFrameClassType Dem_FreezeFrameClass[]=
{
	{ /* FreezeFrameClass */
		.FFKind=DEM_FREEZE_FRAME_NON_OBD,
		.FFRecordNumber=1,
		.FFStorageCondition=DEM_FF_STORAGE_PREFAILED,
		.FFIdClassRef=FreezeFrameClass_FFIdClassRef,
	},
};

static const Dem_FreezeFrameClassType *EHYVideoError_FreezeFrameClassRef[] = 
{
	&Dem_FreezeFrameClass[INDEX_OF_FFCLASS_FreezeFrameClass],
	NULL
};

static const Dem_ExtendedDataRecordClassType *EHYVideoError_ExtendedDataClassRef[] = 
{
	&Dem_ExtendedDataRecord[INDEX_OF_EDRC_ExtendedDataRecordClass_1],
	&Dem_ExtendedDataRecord[INDEX_OF_EDRC_ExtendedDataRecordClass_2],
	NULL
};

static const Dem_FreezeFrameClassType *EHYSensorError_FreezeFrameClassRef[] = 
{
	&Dem_FreezeFrameClass[INDEX_OF_FFCLASS_FreezeFrameClass],
	NULL
};

static const Dem_ExtendedDataRecordClassType *EHYSensorError_ExtendedDataClassRef[] = 
{
	&Dem_ExtendedDataRecord[INDEX_OF_EDRC_ExtendedDataRecordClass_1],
	&Dem_ExtendedDataRecord[INDEX_OF_EDRC_ExtendedDataRecordClass_2],
	NULL
};

static const Dem_FreezeFrameClassType *EHYLCDError_FreezeFrameClassRef[] = 
{
	&Dem_FreezeFrameClass[INDEX_OF_FFCLASS_FreezeFrameClass],
	NULL
};

static const Dem_ExtendedDataRecordClassType *EHYLCDError_ExtendedDataClassRef[] = 
{
	&Dem_ExtendedDataRecord[INDEX_OF_EDRC_ExtendedDataRecordClass_1],
	&Dem_ExtendedDataRecord[INDEX_OF_EDRC_ExtendedDataRecordClass_2],
	NULL
};

static const Dem_FreezeFrameClassType *EHYPowerVoltageError_FreezeFrameClassRef[] = 
{
	&Dem_FreezeFrameClass[INDEX_OF_FFCLASS_FreezeFrameClass],
	NULL
};

static const Dem_ExtendedDataRecordClassType *EHYPowerVoltageError_ExtendedDataClassRef[] = 
{
	&Dem_ExtendedDataRecord[INDEX_OF_EDRC_ExtendedDataRecordClass_1],
	&Dem_ExtendedDataRecord[INDEX_OF_EDRC_ExtendedDataRecordClass_2],
	NULL
};

static const Dem_FreezeFrameClassType *EHYI2CBusError_FreezeFrameClassRef[] = 
{
	&Dem_FreezeFrameClass[INDEX_OF_FFCLASS_FreezeFrameClass],
	NULL
};

static const Dem_ExtendedDataRecordClassType *EHYI2CBusError_ExtendedDataClassRef[] = 
{
	&Dem_ExtendedDataRecord[INDEX_OF_EDRC_ExtendedDataRecordClass_1],
	&Dem_ExtendedDataRecord[INDEX_OF_EDRC_ExtendedDataRecordClass_2],
	NULL
};

static const Dem_FreezeFrameClassType *VIU2IPCanBusOff_FreezeFrameClassRef[] = 
{
	&Dem_FreezeFrameClass[INDEX_OF_FFCLASS_FreezeFrameClass],
	NULL
};

static const Dem_ExtendedDataRecordClassType *VIU2IPCanBusOff_ExtendedDataClassRef[] = 
{
	&Dem_ExtendedDataRecord[INDEX_OF_EDRC_ExtendedDataRecordClass_1],
	&Dem_ExtendedDataRecord[INDEX_OF_EDRC_ExtendedDataRecordClass_2],
	NULL
};

static const Dem_FreezeFrameClassType *LostCommunicationWithVIU2_FreezeFrameClassRef[] = 
{
	&Dem_FreezeFrameClass[INDEX_OF_FFCLASS_FreezeFrameClass],
	NULL
};

static const Dem_ExtendedDataRecordClassType *LostCommunicationWithVIU2_ExtendedDataClassRef[] = 
{
	&Dem_ExtendedDataRecord[INDEX_OF_EDRC_ExtendedDataRecordClass_1],
	&Dem_ExtendedDataRecord[INDEX_OF_EDRC_ExtendedDataRecordClass_2],
	NULL
};

static const Dem_EventParameterType EventParameterList[] = 
{
	{
		.EventID=DEM_EVENT_ID_EHYVideoError,
		.EventKind=DEM_EVENT_KIND_SWC,
		.EventClass=&EventClass_EventClass_EHYVideoError,
		.FreezeFrameClassRef=EHYVideoError_FreezeFrameClassRef,
		.ExtendedDataClassRef=EHYVideoError_ExtendedDataClassRef,
		.CallbackInitMForEFnc=NULL,
		.DTCClassRef=&DTCClassRef_DTCClass_EHYVideoError,
		.Arc_EOL=FALSE,
	},
	{
		.EventID=DEM_EVENT_ID_EHYSensorError,
		.EventKind=DEM_EVENT_KIND_SWC,
		.EventClass=&EventClass_EventClass_EHYSensorError,
		.FreezeFrameClassRef=EHYSensorError_FreezeFrameClassRef,
		.ExtendedDataClassRef=EHYSensorError_ExtendedDataClassRef,
		.CallbackInitMForEFnc=NULL,
		.DTCClassRef=&DTCClassRef_DTCClass_EHYSensorError,
		.Arc_EOL=FALSE,
	},
	{
		.EventID=DEM_EVENT_ID_EHYLCDError,
		.EventKind=DEM_EVENT_KIND_SWC,
		.EventClass=&EventClass_EventClass_EHYLCDError,
		.FreezeFrameClassRef=EHYLCDError_FreezeFrameClassRef,
		.ExtendedDataClassRef=EHYLCDError_ExtendedDataClassRef,
		.CallbackInitMForEFnc=NULL,
		.DTCClassRef=&DTCClassRef_DTCClass_EHYLCDError,
		.Arc_EOL=FALSE,
	},
	{
		.EventID=DEM_EVENT_ID_EHYPowerVoltageError,
		.EventKind=DEM_EVENT_KIND_SWC,
		.EventClass=&EventClass_EventClass_EHYPowerVoltageError,
		.FreezeFrameClassRef=EHYPowerVoltageError_FreezeFrameClassRef,
		.ExtendedDataClassRef=EHYPowerVoltageError_ExtendedDataClassRef,
		.CallbackInitMForEFnc=NULL,
		.DTCClassRef=&DTCClassRef_DTCClass_EHYPowerVoltageError,
		.Arc_EOL=FALSE,
	},
	{
		.EventID=DEM_EVENT_ID_EHYI2CBusError,
		.EventKind=DEM_EVENT_KIND_SWC,
		.EventClass=&EventClass_EventClass_EHYI2CBusError,
		.FreezeFrameClassRef=EHYI2CBusError_FreezeFrameClassRef,
		.ExtendedDataClassRef=EHYI2CBusError_ExtendedDataClassRef,
		.CallbackInitMForEFnc=NULL,
		.DTCClassRef=&DTCClassRef_DTCClass_EHYI2CBusError,
		.Arc_EOL=FALSE,
	},
	{
		.EventID=DEM_EVENT_ID_VIU2IPCanBusOff,
		.EventKind=DEM_EVENT_KIND_SWC,
		.EventClass=&EventClass_EventClass_VIU2IPCanBusOff,
		.FreezeFrameClassRef=VIU2IPCanBusOff_FreezeFrameClassRef,
		.ExtendedDataClassRef=VIU2IPCanBusOff_ExtendedDataClassRef,
		.CallbackInitMForEFnc=NULL,
		.DTCClassRef=&DTCClassRef_DTCClass_VIU2IPCanBusOff,
		.Arc_EOL=FALSE,
	},
	{
		.EventID=DEM_EVENT_ID_LostCommunicationWithVIU2,
		.EventKind=DEM_EVENT_KIND_SWC,
		.EventClass=&EventClass_EventClass_LostCommunicationWithVIU2,
		.FreezeFrameClassRef=LostCommunicationWithVIU2_FreezeFrameClassRef,
		.ExtendedDataClassRef=LostCommunicationWithVIU2_ExtendedDataClassRef,
		.CallbackInitMForEFnc=NULL,
		.DTCClassRef=&DTCClassRef_DTCClass_LostCommunicationWithVIU2,
		.Arc_EOL=FALSE,
	},
	{
		.Arc_EOL=TRUE
	}
};

static const Dem_ConfigSetType DemConfig = 
{
	.EventParameter=EventParameterList,
};

const Dem_ConfigType DEM_Config = { .ConfigSet = &DemConfig };

#ifdef USE_NVM
FreezeFrameRecType * const FreezeFrameMirrorBuffer[DEM_MAX_NUMBER_FF_DATA_PRI_MEM] = 
{
	(FreezeFrameRecType*)&NvM_Block_TBD_DataGroup_RAM[0],
	(FreezeFrameRecType*)&NvM_Block_TBD_DataGroup_RAM[1],
	(FreezeFrameRecType*)&NvM_Block_TBD_DataGroup_RAM[2],
	(FreezeFrameRecType*)&NvM_Block_TBD_DataGroup_RAM[3],
	(FreezeFrameRecType*)&NvM_Block_TBD_DataGroup_RAM[4],
	(FreezeFrameRecType*)&NvM_Block_TBD_DataGroup_RAM[5],
	(FreezeFrameRecType*)&NvM_Block_TBD_DataGroup_RAM[6],
	(FreezeFrameRecType*)&NvM_Block_TBD_DataGroup_RAM[7],
};

const NvM_BlockIdType FreezeFrameBlockId[DEM_MAX_NUMBER_FF_DATA_PRI_MEM] = 
{
	NVM_BLOCK_ID_TBD_0,
	NVM_BLOCK_ID_TBD_1,
	NVM_BLOCK_ID_TBD_2,
	NVM_BLOCK_ID_TBD_3,
	NVM_BLOCK_ID_TBD_4,
	NVM_BLOCK_ID_TBD_5,
	NVM_BLOCK_ID_TBD_6,
	NVM_BLOCK_ID_TBD_7,
};

const NvM_BlockIdType HealingBlockId = NVM_BLOCK_ID_TBD;
#endif /* USE_DCM */

/* ============================ [ LOCALS    ] ====================================================== */
/* ============================ [ FUNCTIONS ] ====================================================== */
#endif
